<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>终端信息管理</title>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<link href="../../pages/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../pages/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
<link rel="stylesheet" href="../../pages/bootstrap/animate.min.css">
<link rel="stylesheet" href="../../pages/common/styles/common.css">
<script src="../../pages/jquery/jquery-1.12.4.min.js"></script>
<script src="../../pages/bootstrap/js/bootstrap.min.js"></script>
<script src="../../pages/common/js/bootstrap-grid.js"></script>
<script src="../../pages/common/js/common.js"></script>
<script src="../../pages/scrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
<link href="../../pages/scrollbar/jquery.mCustomScrollbar.css" rel="stylesheet" />
<script src="../../pages/fileinput/fileinput.min.js"></script>  
<link rel="stylesheet" href="../../pages/fileinput/fileinput.min.css">

</head>
<body class="animated fadeInRight">
	<div class="tabBar">
		<div class="tab">
			<img src="../../pages/images/tab_terminal_manager.png">
			终端信息管理
		</div>
		<div class="tab">
			<img src="../../pages/images/tab_terminal_add.png">
			终端信息新建
		</div>
		<div class="tab">
			<img src="../../pages/images/tab_terminal_update.png">
			终端信息修改
		</div>
		<div class="tab">
			<img src="../../pages/images/tab_terminal_import.png">
			终端信息批量导入
		</div>
	</div>
	<div class="tab-main tab-active">
		<div>
			<a id="btnAdd" class="a-btn-blue"><span class="glyphicon glyphicon-plus font-size-12px"></span>&nbsp;新增</a>
			<a id="btnEdit" class="a-btn-green"><span class="glyphicon glyphicon-pencil font-size-12px"></span>&nbsp;修改</a>
			<a id="btnDel" class="a-btn-red"><span class="glyphicon glyphicon-remove font-size-12px"></span>&nbsp;删除</a>
			
			<a id="advancedSearchbtnTerminal" class="a-btn-gray2 inline pull-right" style="color: #03a9f4;text-decoration: none">
			<span id="advancedSearchTerminalText">高级搜索</span>&nbsp;
			<span id="advancedSearchTerminalSpan" class="glyphicon glyphicon-chevron-down" title="高级搜索"></span></a>
			
			<div class="pull-right input-group" role="group" style="width: 30%;margin-right: 10px">
				<input id="searchFieldTerminal" type="text" class="form-control" placeholder="输入终端型号或MAC" aria-describedby="basic-addon2" >
				<span class="input-group-addon search-cusor" id="btnSearchTerminal"><img alt="" src="../../pages/images/search.png"></span>
			</div>
		</div>
		
		<div id="advancedSearchTerminal" style="margin-top:10px; display: none;">
			<table style="float: right;margin-right: 100px;margin-top: 10px;">
				<tr>
					<td style="padding-right: 10px;">
					</td>
					<td style="width: 300px;">
						<input id="searchSystemVersion" type="text" class="form-control" style="width: 250px;" placeholder="请输入操作系统版本">
					</td>
					<td style="padding-right: 10px;">
					</td>
					<td style="width: 300px;">
						<input id="searchCpuVersion" type="text" class="form-control" style="width: 250px;" placeholder="请输入CPU型号">
					</td>
					
				</tr>
			</table>
		</div>
		
		
		<div>
			<table id="terminalTable" class="table table-striped table-hover">
			  <thead>
			    <tr>
			      <th field="terminalVersion">终端型号</th>
			      <th field="mac">MAC</th>
			      <th field="operatingSystemVersion">操作系统版本</th>
			      <th field="cpuVersion">CPU型号</th>
			      <th field="maxExtCapacity">最大存储扩展容量</th>
			      <th field="screenFbl">分辨率</th>
			    </tr>
			  </thead>
			  <tbody>
			  </tbody>
			</table>
			<div style="margin-bottom: 10px;">
			  <ul id="terminalTable_page" class="pagination">
			  	<!-- 
			    <li><a>上一页</a></li>
			    <li class="active"><a>1</a></li>
			    <li><a>2</a></li>
			    <li><a>3</a></li>
			    <li><a>4</a></li>
			    <li><a>5</a></li>
			    <li><a>6</a></li>
			    <li><a>7</a></li>
			    <li><a>8</a></li>
			    <li><a>9</a></li>
			    <li><a>10</a></li>
			    <li><a>下一页</a></li>-->
			  </ul>
			   
			  <div class="pull-right" style="margin-top: 25px;padding-right: px">
			  	<!-- 显示分页参数  -->
			  </div>
			 </div>
		</div>
	</div>
	<div class="tab-main">
		<table class="table-form" style="width: 100%;">
			<tr>
				 <td colspan="4" style="border-bottom: 2px solid rgb(154,221,251);padding: 0 0 0 0;">
				 	<div class="basetitle">
				 		<img alt="" src="../../pages/images/baseInfo.png">&nbsp;基本信息
				 	</div>
				 </td>
			</tr>
			
			<tr>
				<th width="10%">终端品牌</td>
				<td width="40%">
					<input id="brand" type="text" class="form-control inline"  aria-describedby="basic-addon1">
				</td>
				<th width="10%">终端型号</th>
				<td width="40%">
					<input id="terminalVersion" type="text" class="form-control"  aria-describedby="basic-addon1">
				</td>
			</tr>
			
			
			<tr>
				<th width="10%"><font color="red">*</font>MAC</th>
				<td width="40%">
					<input id="mac" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			
			<tr>
				 <td colspan="4" style="border-bottom: 2px solid rgb(154,221,251);padding: 0 0 0 0;">
				 	<div class="basetitle">
				 		<img alt="" src="../../pages/images/baseInfo.png">&nbsp;基本参数
				 	</div>
				 </td>
			</tr>
			
			<tr>
				<th width="12%">主芯片：CPU品牌</th>
				<td width="40%">
					<input id="cpuBrand" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="12%">主芯片：CPU频率</th>
				<td width="40%">
					<input id="cpuFrequency" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="12%">主芯片:CPU核数</th>
				<td width="40%">
					<input id="cpuCoreNum" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="12%">主芯片:CPU型号</th>
				<td width="40%">
					<input id="cpuVersion" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			
			
			<tr>
				<th width="10%">RAM</th>
				<td width="40%">
					<input id="ram" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">最大存储扩展容量</th>
				<td width="40%">
					<input id="maxExtCapacity" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">操作系统</th>
				<td width="40%">
					<input id="operatingSystem" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">数据传输接口</th>
				<td width="40%">
					<input id="dataTransInterface" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>

			<tr>
				<th width="10%">操作系统版本</th>
				<td width="40%">
					<input id="operatingSystemVersion" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">ROM</th>
				<td width="40%">
					<input id="rom" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			
			<tr>
				<th width="10%">摄像头数量</th>
				<td width="40%">
					<input id="cameraNum" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">摄像头像素</th>
				<td width="40%">
					<input id="cameraPixel" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">镜头尺寸</th>
				<td width="40%">
					<input id="lensSize" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">分辨率</th>
				<td width="40%">
					<input id="screenFbl" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				 <td colspan="4" style="border-bottom: 2px solid rgb(154,221,251);padding: 0 0 0 0;">
				 	<div class="basetitle">
				 		<img alt="" src="../../pages/images/baseInfo.png">&nbsp;其他参数
				 	</div>
				 </td>
			</tr>
			
			
			<tr>
				<th width="10%">入网型号</th>
				<td width="40%">
					<input id="netVersion" type="text" class="form-control"  aria-describedby="basic-addon1">
				</td>
				
			</tr>
			<tr>
				<th width="10%">上市年份</th>
				<td width="40%">
					<input id="launchYear" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">上市月份</th>
				<td width="40%">
					<input id="launchMonth" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">机身长度</th>
				<td width="40%">
					<input id="length" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">机身宽度</th>
				<td width="40%">
					<input id="width" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">机身厚度</th>
				<td width="40%">
					<input id="thick" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">机身重量</th>
				<td width="40%">
					<input id="weight" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">机身材质分类</th>
				<td width="40%">
					<input id="bodyMaterialCatergory" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">镜架材质分类</th>
				<td width="40%">
					<input id="holderMaterialCatergory" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">镜头材质分类</th>
				<td width="40%">
					<input id="headerMaterialCatergory" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				
				<th width="10%">包装清单</th>
				<td width="40%">
					<input id="packingList" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			
			<tr>
		
				<th width="10%">电池容量(mAh)</th>
				<td width="40%">
					<input id="batteryCapacity" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">待机时间(小时)</th>
				<td width="40%">
					<input id="awaitRunTime" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			
			<tr>
				<th width="10%">可运行时间</th>
				<td width="40%">
					<input id="availRunTime" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">屏幕像素密度</th>
				<td width="40%">
					<input id="screenDensity" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			
			<tr>
				<td colspan="4" style="text-align: center;">
					<a id="save" class="a-btn-submit" onclick="addTerminalManagerInfo()" >提 &nbsp;&nbsp;交</a>
					<a id="reset" class="a-btn-cancel" onclick="resetTerminalManagerInfo()" style="margin-left: 50px;">重 &nbsp;&nbsp;置</a>
				</td>
			</tr>
		</table>
	</div>
	<div class="tab-main">
		<table class="table-form" style="width: 100%;">
			<tr>
				 <td colspan="4" style="border-bottom: 2px solid rgb(154,221,251);padding: 0 0 0 0;">
				 	<div class="basetitle">
				 		<img alt="" src="../../pages/images/baseInfo.png">&nbsp;基本信息
				 	</div>
				 </td>	
			</tr>
			<tr style="display: none;">
				<th width="10%">id</td>
				<td width="40%">
					<input id="u_id" type="text" class="form-control inline"  aria-describedby="basic-addon1">
				</td>
			</tr>
			
			<tr>
				<th width="10%">终端品牌</td>
				<td width="40%">
					<input id="u_brand" type="text" class="form-control inline"  aria-describedby="basic-addon1">
				</td>
				<th width="10%">终端型号</th>
				<td width="40%">
					<input id="u_terminalVersion" type="text" class="form-control"  aria-describedby="basic-addon1">
				</td>
			</tr>
			
			<tr>
				<th width="10%"><font color="red">*</font>MAC</th>
				<td width="40%">
					<input id="u_mac" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			
			<tr>
				 <td colspan="4" style="border-bottom: 2px solid rgb(154,221,251);padding: 0 0 0 0;">
				 	<div class="basetitle">
				 		<img alt="" src="../../pages/images/baseInfo.png">&nbsp;基本参数
				 	</div>
				 </td>
			<tr>
				<th width="12%">主芯片：CPU品牌</th>
				<td width="40%">
					<input id="u_cpuBrand" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="12%">主芯片：CPU频率</th>
				<td width="40%">
					<input id="u_cpuFrequency" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="12%">主芯片:CPU核数</th>
				<td width="40%">
					<input id="u_cpuCoreNum" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="12%">主芯片:CPU型号</th>
				<td width="40%">
					<input id="u_cpuVersion" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">操作系统</th>
				<td width="40%">
					<input id="u_operatingSystem" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">数据传输接口</th>
				<td width="40%">
					<input id="u_dataTransInterface" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">操作系统版本</th>
				<td width="40%">
					<input id="u_operatingSystemVersion" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">ROM</th>
				<td width="40%">
					<input id="u_rom" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">RAM</th>
				<td width="40%">
					<input id="u_ram" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">最大存储扩容量</th>
				<td width="40%">
					<input id="u_maxExtCapacity" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">摄像头数量</th>
				<td width="40%">
					<input id="u_cameraNum" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">摄像头像素</th>
				<td width="40%">
					<input id="u_cameraPixel" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">镜头尺寸</th>
				<td width="40%">
					<input id="u_lensSize" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">分辨率</th>
				<td width="40%">
					<input id="u_screenFbl" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			
			
			<tr>
				 <td colspan="4" style="border-bottom: 2px solid rgb(154,221,251);padding: 0 0 0 0;">
				 	<div class="basetitle">
				 		<img alt="" src="../../pages/images/baseInfo.png">&nbsp;其他参数
				 	</div>
				 </td>
			</tr>
			
			
			<tr>
				<th width="10%">入网型号</th>
				<td width="40%">
					<input id="u_netVersion" type="text" class="form-control"  aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">上市年份</th>
				<td width="40%">
					<input id="u_launchYear" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">上市月份</th>
				<td width="40%">
					<input id="u_launchMonth" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">机身长度</th>
				<td width="40%">
					<input id="u_length" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">机身宽度</th>
				<td width="40%">
					<input id="u_width" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">机身厚度</th>
				<td width="40%">
					<input id="u_thick" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">机身重量</th>
				<td width="40%">
					<input id="u_weight" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">机身材质分类</th>
				<td width="40%">
					<input id="u_bodyMaterialCatergory" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">镜架材质分类</th>
				<td width="40%">
					<input id="u_holderMaterialCatergory" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			<tr>
				<th width="10%">镜头材质分类</th>
				<td width="40%">
					<input id="u_headerMaterialCatergory" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">包装清单</th>
				<td width="40%">
					<input id="u_packingList" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			
			<tr>
				<th width="10%">电池容量(mAh)</th>
				<td width="40%">
					<input id="u_batteryCapacity" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">待机时间(小时)</th>
				<td width="40%">
					<input id="u_awaitRunTime" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			
			<tr>
				<th width="10%">可运行时间</th>
				<td width="40%">
					<input id="u_availRunTime" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
				<th width="10%">屏幕像素密度</th>
				<td width="40%">
					<input id="u_screenDensity" type="text" class="form-control" aria-describedby="basic-addon1">
				</td>
			</tr>
			
			<tr>
				<td colspan="4" style="text-align: center;">
					<a id="update" class="a-btn-submit" onclick="updateTerminalManagerInfo()">提 &nbsp;&nbsp;交</a>
				</td>
			</tr>
		</table>
	</div>
	
	<!-- 终端倒入模块 -->
	<div class="tab-main" >	
		<div>
			<form id="uploadForm">
				<table style="width: 100%">
					<tr>
						<th width="180">
							用户批量导入(*.xlsx\*.xls)		
						</th>
						<td width="50%">
							<input id="file" type="file"  class="row" name="file">
						</td>
						<td style="padding-left: 5px;">
							<a class="a-btn-green" onclick="importUsers()">导入文件</a>
							<a class="a-btn-blue" onclick="downloadTemp()">下载模板</a>
						</td>
					</tr>
					<tr>
						<td>
							<a class="a-btn-blue" onclick="confirmTempTerminal()">确定</a>		
						</td>
					</tr>
				</table>
			</form>
		</div>
		<div>
			<table id="terminalTempTable" class="table table-striped table-hover">
			  <thead>
			    <tr>
			      <th field="terminalVersion">终端型号</th>
			      <th field="mac">MAC</th>
			      <th field="operatingSystemVersion">操作系统版本</th>
			      <th field="cpuVersion">CPU型号</th>
			      <th field="maxExtCapacity">终端型号</th>
			      <th field="screenFbl">分辨率</th>
			    </tr>
			  </thead>
			  <tbody>
			  </tbody>
			</table>
			<div style="margin-bottom: 10px;">
			  <ul id="terminalTempTable_page" class="pagination">
			  	<!-- 
			    <li><a>上一页</a></li>
			    <li class="active"><a>1</a></li>
			    <li><a>2</a></li>
			    <li><a>3</a></li>
			    <li><a>4</a></li>
			    <li><a>5</a></li>
			    <li><a>6</a></li>
			    <li><a>7</a></li>
			    <li><a>8</a></li>
			    <li><a>9</a></li>
			    <li><a>10</a></li>
			    <li><a>下一页</a></li>-->
			  </ul>
			   
			  <div class="pull-right" style="margin-top: 25px;padding-right: px">
			  	<!-- 显示分页参数  -->
			  </div>
			 </div>
		</div>
	</div>
	 
</body>
<script type="text/javascript">

$(document).ready(function() {
	$("#terminalTable").initGrid(15);
	$(".tab").eq(0).click();
    query();
    initFileInput("file");
});

function query(){
	var pageSize = parseInt(window["terminalTable_page"].pageSize);
	var pageNum = parseInt(window["terminalTable_page"].pageNum);
	$.ajax({
        type: "post",
        dataType: "json",
        url: '${ctx}/terminal/getTerminalList',
        data:{
        	pageNum:pageNum,
        	pageSize:pageSize,
        	operatingSystemVersion:$("#searchSystemVersion").val(),
        	cpuVersion:$("#searchCpuVersion").val(),
        	searchField:$("#searchFieldTerminal").val()
        },
        success: function (data) {
        	$("#terminalTable").loadGrid(data);
        },
		error:function(){
		}
    });
}


//初始化导入文件样式
function initFileInput(ctrlName) {      
	 var control = $('#' + ctrlName);   
	 control.fileinput({  
	     language: 'zh', //设置语言  
	     showUpload: false, //是否显示上传按钮  
	     showPreview:false,//显示预览框
	     showRemove:true,  
	      dropZoneEnabled: false,  
	     showCaption: true,//是否显示标题  
	     allowedPreviewTypes: [''],  
	        allowedFileTypes: ['image'],  
	        allowedFileExtensions:  ['xlsx', 'xls'],  
	        maxFileSize : 2000,  
	        maxFileCount: 1,  
	        uploadAsync: false, //同步上传    
	 }); 
}



/**
 * 点击新增，跳转到新增界面
 * 执行提交和重置事件
 */
$("#btnAdd").on("click",function(){
	$(".tab").eq(1).click();
});
function addTerminalManagerInfo(){
		var mac = document.getElementById("mac"); 
		if(mac.value == null||mac.value==""){
			$.MsgBox.Alert("提示","MAC不能为空!");
			$("#mac").focus();
		}else{
			$.MsgBox.Confirm("提示","确定添加",function(){
				$.ajax({
			        type: "post",
			        dataType: "json",
			        url: '${ctx}/terminal/addTerminal',
			        data:{
			        	brand:$("#brand").val(),
			        	terminalVersion:$("#terminalVersion").val(),
			        	netVersion:$("#netVersion").val(),
			        	launchYear:$("#launchYear").val(),
			        	launchMonth:$("#launchMonth").val(),
			        	mac:$("#mac").val(),
			        	width:$("#width").val(),
			        	length:$("#length").val(),
			        	thick:$("#thick").val(),
			        	color:$("#thick").val(),
			        	weight:$("#weight").val(),
			        	bodyMaterialCatergory:$("#bodyMaterialCatergory").val(),
			        	holderMaterialCatergory:$("#holderMaterialCatergory").val(),
			        	headerMaterialCatergory:$("#headerMaterialCatergory").val(),
			        	operatingSystem:$("#operatingSystem").val(),
			        	operatingSystemVersion:$("#operatingSystemVersion").val(),
			        	rom:$("#rom").val(),
			        	ram:$("#ram").val(),
			        	cpuBrand:$("#cpuBrand").val(),
			        	cpuFrequency:$("#cpuFrequency").val(),
			        	cpuCoreNum:$("#cpuCoreNum").val(),
			        	cpuVersion:$("#cpuVersion").val(),
			        	maxExtCapacity:$("#maxExtCapacity").val(),
			        	cameraNum:$("#cameraNum").val(),
			        	cameraPixel:$("#cameraPixel").val(),
			        	lensSize:$("#lensSize").val(),
			        	batteryCapacity:$("#batteryCapacity").val(),
			        	screenFbl:$("#screenFbl").val(),
			        	awaitRunTime:$("#awaitRunTime").val(),
			        	screenDensity:$("#screenDensity").val(),
			        	availRunTime:$("#availRunTime").val(),
			        	dataTransInterface:$("#dataTransInterface").val(),
			        	packingList:$("#packingList").val()
			        },
			        success: function (data) {
			        	if(data.status=="1"){
			        		$.MsgBox.Alert("提示",data.msg); 
			        		$(".tab-main tr td input").val("");
			        		$(".tab").eq(0).click();
				        	query();
			        	}else{
			        		$.MsgBox.Alert("提示",data.msg);
			        		$("#account").focus();
			        	}
			        },
					error:function(){
						$.MsgBox.Alert("提示",data.msg);
						$("#account").focus();
					}
			    });
			});
		}
}

//新增用户信息重置
function resetTerminalManagerInfo(){
	$.MsgBox.Confirm("提示","确定重置信息？",function(){
		$(".tab-main tr td input").val("");
		$("#account").focus();
	});
}

//修改用户信息
$("#btnEdit").on("click",function(){
	var result = $("#terminalTable").getSelections();
	if(parseInt(result.length)==0){
		$.MsgBox.Alert("提示","请选择一条记录!"); 
	}else if(parseInt(result.length)==1){
		$(".tab").eq(2).click();
		$("#u_id").val(result[0].id),
    	$("#u_brand").val(result[0].brand),
    	$("#u_terminalVersion").val(result[0].terminalVersion),
    	$("#u_netVersion").val(result[0].netVersion),
    	$("#u_mac").val(result[0].mac),
    	$("#u_launchYear").val(result[0].launchYear),
    	$("#u_launchMonth").val(result[0].launchMonth),
    	$("#u_length").val(result[0].length),
    	$("#u_width").val(result[0].width),
    	$("#u_thick").val(result[0].thick),
    	$("#u_weight").val(result[0].weight),
    	$("#u_bodyMaterialCatergory").val(result[0].bodyMaterialCatergory),
    	$("#u_holderMaterialCatergory").val(result[0].holderMaterialCatergory),
    	$("#u_headerMaterialCatergory").val(result[0].headerMaterialCatergory),
    	$("#u_operatingSystem").val(result[0].operatingSystem),
    	$("#u_operatingSystemVersion").val(result[0].operatingSystemVersion),
    	$("#u_rom").val(result[0].rom),
    	$("#u_ram").val(result[0].ram),
    	$("#u_maxExtCapacity").val(result[0].maxExtCapacity),
    	$("#u_cpuBrand").val(result[0].cpuBrand),
    	$("#u_cpuFrequency").val(result[0].cpuFrequency),
    	$("#u_cpuCoreNum").val(result[0].cpuCoreNum),
    	$("#u_cpuVersion").val(result[0].cpuVersion),
    	$("#u_cameraNum").val(result[0].cameraNum),
    	$("#u_cameraPixel").val(result[0].cameraPixel),
    	$("#u_lensSize").val(result[0].lensSize),
    	$("#u_screenFbl").val(result[0].screenFbl),
    	$("#u_batteryCapacity").val(result[0].batteryCapacity),
    	$("#u_awaitRunTime").val(result[0].awaitRunTime),
    	$("#u_availRunTime").val(result[0].availRunTime),
    	$("#u_screenDensity").val(result[0].screenDensity),
    	$("#u_dataTransInterface").val(result[0].dataTransInterface),
    	$("#u_packingList").val(result[0].packingList)	
	}else{
		$.MsgBox.Alert("提示","只能选择一条记录!");
	}
	
});


 function updateTerminalManagerInfo(){
	 	var mac = document.getElementById("u_mac");
		if(mac.value == null||mac.value==""){
			$.MsgBox.Alert("提示","MAC不能为空!");
			$("#u_mac").focus();
		}else{	
			$.MsgBox.Confirm("提示","确定修改该用户信息？",function(){
				$.ajax({
			        type: "post",
			        dataType: "json",
			        url: '${ctx}/terminal/updateTerminal',
			        data:{
			        	id:$("#u_id").val(),
			        	brand:$("#u_brand").val(),
			        	terminalVersion:$("u_#terminalVersion").val(),
			        	netVersion:$("#u_netVersion").val(),
			        	launchYear:$("#u_launchYear").val(),
			        	launchMonth:$("#u_aunchMonth").val(),
			        	mac:$("#u_mac").val(),
			        	width:$("#u_width").val(),
			        	length:$("#u_length").val(),
			        	thick:$("#u_thick").val(),
			        	color:$("#u_thick").val(),
			        	weight:$("#u_weight").val(),
			        	bodyMaterialCatergory:$("#u_bodyMaterialCatergory").val(),
			        	holderMaterialCatergory:$("#u_holderMaterialCatergory").val(),
			        	headerMaterialCatergory:$("#u_headerMaterialCatergory").val(),
			        	operatingSystem:$("#u_operatingSystem").val(),
			        	operatingSystemVersion:$("#u_operatingSystemVersion").val(),
			        	rom:$("#u_rom").val(),
			        	ram:$("#u_ram").val(),
			        	cpuBrand:$("#u_cpuBrand").val(),
			        	cpuFrequency:$("#u_cpuFrequency").val(),
			        	cpuCoreNum:$("#u_cpuCoreNum").val(),
			        	cpuVersion:$("#u_cpuVersion").val(),
			        	maxExtCapacity:$("#u_maxExtCapacity").val(),
			        	cameraNum:$("#u_cameraNum").val(),
			        	cameraPixel:$("#u_cameraPixel").val(),
			        	lensSize:$("#u_lensSize").val(),
			        	batteryCapacity:$("#u_batteryCapacity").val(),
			        	screenFbl:$("#u_screenFbl").val(),
			        	awaitRunTime:$("#u_awaitRunTime").val(),
			        	screenDensity:$("#u_screenDensity").val(),
			        	availRunTime:$("#u_availRunTime").val(),
			        	dataTransInterface:$("#u_dataTransInterface").val(),
			        	packingList:$("#u_packingList").val()
			        },
			        success: function (data) {
			        	if(data.status=="1"){
			        		$.MsgBox.Alert("提示",data.msg);
			        		$(".tab-main tr td input").val("");
				        	$(".tab").eq(0).click();
				        	query();
			        	}else{
			        		$.MsgBox.Alert("提示",data.msg); 
			        		$("#brand").focus();
			        	}
			        },
					error:function(){
						$.MsgBox.Alert("提示",data.msg);
					}
			    });
			});
		}
}

//删除数据
 $("#btnDel").on("click",function(){
 	var result = $("#terminalTable").getSelections();
 	var terminalIds = [];
 	for(var i=0; i<result.length; i++){
 		terminalIds.push(result[i].id);
 	}
 	if(parseInt(result.length)==0){
 		$.MsgBox.Alert("提示","请选择一条记录!");
 	}else{
 		$.MsgBox.Confirm("提示","确定删除？",function(){
 			$.ajax({
 	 	        type: "post",
 	 	        dataType: "json",
 	 	        url: '${ctx}/terminal/deleteTerminals',
 	 	        data:{
 	 	        	"terminalIds":terminalIds.join(",")
 	 	        },
 	 	        success: function (data) {
 	 	        	if(data.status=='1'){
 	 	        		$.MsgBox.Alert("提示",data.msg); 
 	 	        		query();
 	 	        	}else{
 	 	        		$.MsgBox.Alert("提示",data.msg);
 	 	        	}
 	 	        },
 	 			error:function(){
 	 				$.MsgBox.Alert("提示",data.msg);
 	 			}
 	 	    }); 
 		});
 	}
 });




 /**
  * 文件导入
  */
function importUsers(){
	$.MsgBox.Confirm("提示","确定导入?",function(){
		$.ajax({
		url : '${ctx}/terminal/exportTerminals',
		type : 'POST',
		cache : false,
		data : new FormData($('#uploadForm')[0]),
		processData : false,
		contentType : false
	}).done(function(res) {
		if(res.status=="1"){
			$.MsgBox.Alert("提示",data.msg);
			$("#terminalTempTable").initGrid(0);
			$("#terminalTempTable").loadGrid(JSON.parse(res.data));
		}else{
			$.MsgBox.Alert("提示",data.msg);
		}
	}).fail(function(res) {
		$.MsgBox.Alert("提示",data.msg);
		});
	});
}
 	
 /**
  * 文件导出
 */
function downloadTemp() {
	window.location.href = "${ctx}/terminal/downloadTemp";
}

/**
 * 把数据保持入库
 */
function confirmTempTerminal(){
	var rows = $("#terminalTempTable").getSelections();
	alert(rows.length);
	if(rows.length < 1){
		$.MsgBox.Alert("提示","请选择一条记录!"); 
		return ;
	}
	var terminalList = new Array();
	for(var i=0; i<rows.length; i++){
		var terminal = new Object();
		terminal.brand = rows[i].brand;
		terminal.terminalVersion = rows[i].terminalVersion;
		terminal.netVersion = rows[i].netVersion;
		terminal.launchYear = rows[i].launchYear;
		terminal.launchMonth = rows[i].launchMonth;
		terminal.mac = rows[i].mac;
		terminal.width = rows[i].width;
		terminal.length = rows[i].length;
		terminal.thick = rows[i].thick;
		terminal.color = rows[i].color;
		terminal.weight = rows[i].weight;
		terminal.bodyMaterialCatergory = rows[i].bodyMaterialCatergory;
		terminal.holderMaterialCatergory = rows[i].holderMaterialCatergory;
		terminal.headerMaterialCatergory = rows[i].headerMaterialCatergory;
		terminal.operatingSystem = rows[i].operatingSystem;
		terminal.operatingSystemVersion = rows[i].operatingSystemVersion;
		terminal.rom = rows[i].rom;
		terminal.ram = rows[i].ram;
		terminal.cpuBrand = rows[i].cpuBrand;
		terminal.cpuFrequency = rows[i].cpuFrequency;
		terminal.cpuCoreNum = rows[i].cpuCoreNum;
		terminal.cpuVersion = rows[i].cpuVersion;
		terminal.maxExtCapacity = rows[i].maxExtCapacity;
		terminal.cameraNum = rows[i].cameraNum;
		terminal.cameraPixel = rows[i].cameraPixel;
		terminal.lensSize = rows[i].lensSize;
		terminal.batteryCapacity = rows[i].batteryCapacity;
		terminal.screenFbl = rows[i].screenFbl;
		terminal.awaitRunTime = rows[i].awaitRunTime;
		terminal.screenDensity = rows[i].screenDensity;
		terminal.availRunTime = rows[i].availRunTime;
		terminal.availRunTime = rows[i].dataTransInterface;
		terminal.dataTransInterface = rows[i].packingList;
		terminalList.push(terminal);
	}
 		
	$.ajax({
        type: "post",
        dataType: "json",
        url: '${ctx}/terminal/confirmTempTerminals',
        data:{
        	"terminalListString":JSON.stringify(terminalList)
        },
        success: function (data) {
        	if(data.status=='1'){
        		query();
        		$.MsgBox.Alert("提示",data.msg);
        		$('#terminalTempTable').deleteSelections();
        	}else{
        		$.MsgBox.Alert("提示",data.msg);
        	}
        },
		error:function(){
			$.MsgBox.Alert("提示",data.msg);
		}
    });	
}

$("#advancedSearchbtnTerminal").on("click",function(){
	 if($("#advancedSearchTerminal").css('display')=="block"){
	    $("#advancedSearchTerminalText").html('高级搜索');
		$("#advancedSearchTerminalSpan").removeClass('glyphicon glyphicon-chevron-up');
		$("#advancedSearchTerminalSpan").addClass('glyphicon glyphicon-chevron-down');
		$("#advancedSearchTerminal").css("display","none");
		$("#searchSystemVersion").val('');
    	$("#searchCpuVersion").val('');
	 }else{
	    $("#advancedSearchTerminalText").html('收起条件');
		$("#advancedSearchTerminalSpan").removeClass('glyphicon glyphicon-chevron-down');
		$("#advancedSearchTerminalSpan").addClass('glyphicon glyphicon-chevron-up');
		$("#advancedSearchTerminal").css("display","block");
	 }
});




$("#btnSearchTerminal").click(function(){
	query();
});

</script>
</html>